home *** CD-ROM | disk | FTP | other *** search
- CHOOSEFONT API DEMO ⌐ Mike McGrath(UK)1998 emailto:mikem@clara.net
- ===================================================================
-
- This demonstration illustrates the steps required by the windows font dialog box in allowing the
- user to select a font. These steps are normally automated but the demo now requires them to be
- taken manually in order to understand them fully.
-
- DECLARATION:
- ============
- Declare Function CHOOSEFONT Lib "comdlg32.dll" Alias "ChooseFontA" (pChoosefont As CHOOSEFONT) As Long
-
-
- VARIABLE STRUCTURE:
- ===================
- Public Type CHOOSEFONT
- lStructSize As Long ' sets size in bytes of variable structure
- hwndOwner As Long ' caller's window handle
- hdc As Long ' printer DC/IC or NULL.................................ignore unless CF_PRINTERFONTS or CF_BOTH flags set
- lpLogFont As String ' ptr. to a LOGFONT struct if used.................set CF_INITTOLOGFONTSTRUCT to initialise
- iPointSize As Long ' size in points(*10) of selected font ...............sets this value after the user closes the dialog box.
- flags As Long ' enum. type flags
- rgbColors As Long ' returned text color
- lCustData As Long ' data passed to hook fn...................................ignored unless the CF_ENABLEHOOK flag is set
- lpfnHook As Long ' ptr. to hook function.....................................ignored unless the CF_ENABLEHOOK flag is set
- lpTemplateName As String ' custom template name...................................ignored unless the CF_ENABLETEMPLATE flag is set
- hInstance As Long ' instance handle of.EXE that contains cust. dlg. template
- ' ( If neither CF_ENABLETEMPLATEHANDLE nor CF_ENABLETEMPLATE is set, this member is ignored.)
- lpszStyle As String ' returns style field here must be LF_FACESIZE or bigger.........ignore unless CF_USESTYLE flag is set
- nFontType As Integer ' same value reported to the EnumFonts call back with the extra FONTTYPE_bits added
- MISSING_ALIGNMENT As Integer
- nSizeMin As Long ' minimum pt size allowed &.......................................only if the CF_LIMITSIZE flag is specified.
- nSizeMax As Long ' max pt size allowed if CF_LIMITSIZE is used.................only if the CF_LIMITSIZE flag is specified.
- End Type
-
-
- FLAGS:
- ======
- Public Const CF_SCREENFONTS = &H1
- Public Const CF_PRINTERFONTS = &H2
- Public Const CF_BOTH = (CF_SCREENFONTS Or CF_PRINTERFONTS)
- Public Const CF_SHOWHELP = &H4&
- Public Const CF_ENABLEHOOK = &H8&
- Public Const CF_ENABLETEMPLATE = &H10&
- Public Const CF_ENABLETEMPLATEHANDLE = &H20&
- Public Const CF_INITTOLOGFONTSTRUCT = &H40&
- Public Const CF_USESTYLE = &H80&
- Public Const CF_EFFECTS = &H100&
- Public Const CF_APPLY = &H200&
- Public Const CF_ANSIONLY = &H400&
- Public Const CF_SCRIPTSONLY = CF_ANSIONLY
- Public Const CF_NOVECTORFONTS = &H800&
- Public Const CF_NOOEMFONTS = CF_NOVECTORFONTS
- Public Const CF_NOSIMULATIONS = &H1000&
- Public Const CF_LIMITSIZE = &H2000&
- Public Const CF_FIXEDPITCHONLY = &H4000&
- Public Const CF_WYSIWYG = &H8000 ' must also have CF_SCREENFONTS CF_PRINTERFONTS
- Public Const CF_FORCEFONTEXIST = &H10000
- Public Const CF_SCALABLEONLY = &H20000
- Public Const CF_TTONLY = &H40000
- Public Const CF_NOFACESEL = &H80000
- Public Const CF_NOSTYLESEL = &H100000
- Public Const CF_NOSIZESEL = &H200000
- Public Const CF_SELECTSCRIPT = &H400000
- Public Const CF_NOSCRIPTSEL = &H800000
- Public Const CF_NOVERTFONTS = &H1000000
-
- Public Const SIMULATED_FONTTYPE = &H8000
- Public Const PRINTER_FONTTYPE = &H4000
- Public Const SCREEN_FONTTYPE = &H2000
- Public Const BOLD_FONTTYPE = &H100
- Public Const ITALIC_FONTTYPE = &H200
- Public Const REGULAR_FONTTYPE = &H400
-
- VARIABLES:
- ==========
- Dim MyChooseFont As CHOOSEFONT
-
- EXECUTION:
- ==========
- MyChooseFont.flags =CC_SCREENFONTS (set flags,"OR" for joint flags)
- MyChooseFont.lStructSize = Len(MyChooseFont) (set size of variable structure)
- MyChooseFont.hwndOwner = Form1.hWnd (get handle of calling window)
- MyChooseFont.lpLogFont = space$(512) (empty buffer to store font details)
- MyChooseFont.nFontType = (returns fonttype and bold/italic details)
- MyChooseFont.rgbColors = (returns selected font color, 0 to 16777215)
-
-
- NOTES:
- ======
- To Install run setup.exe and to Uninstall use Add/remove programs facility in ControlPanel.
- CfDemo requires that you have vb40032.dll on your system.
- MyChooseFont.lplogfont is selected into a byte array only for demo purposes.
- Selected data is shown in yellow and Returned data is shown in blue.
-
- CHOOSEFONT API DEMO ⌐ Mike McGrath(UK)1998 emailto:mikem@clara.net
- Permission is required for anything other than private use of this software and no liability
- whatsoever will be accepted in connection with its use.
-
-
-